package com.qfedu.stussm.controller;

import com.qfedu.stussm.entity.JwDept;
import com.qfedu.stussm.entity.JxDept;
import com.qfedu.stussm.service.intf.JwDeptService;
import com.qfedu.stussm.service.intf.JxDeptService;
import com.qfedu.stussm.vo.DeptR;
import com.qfedu.stussm.vo.PageBeanVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class JxDeptController {
    @Autowired
    private JxDeptService jxdeptService;

    @RequestMapping("api/stussm/jxinsert.do")
    public DeptR insert(JxDept jxDept){
        System.out.println(jxDept);
        return jxdeptService.insert(jxDept);
    }



    @GetMapping("api/stussm/jxselect.do")
    public PageBeanVo select(String name,int page,int limit){
        PageBeanVo select = jxdeptService.select(name,page, limit);
        System.out.println(select);
        //   System.out.println("controller:"+name);
        return select;
    }

    @GetMapping("api/stussm/jxdel.do")
    public DeptR del(Integer id){
        System.out.println(id);
        return jxdeptService.del(id);
    }

    @PostMapping("api/stussm/jxupdate.do")
    public DeptR update(JxDept jxDept){
        DeptR update = jxdeptService.update(jxDept);
        System.out.println(jxDept);
        return update;
    }
    @PostMapping("api/stussm/jxdelmany.do")
    public DeptR dele(Integer[] id) {
        System.out.println("ids:" + id);
        if (id == null) {
            return DeptR.fail();
        } else {
            for (Integer i : id) {
                System.out.println(i);
            }
            return jxdeptService.dele(id);
        }
    }
}
